﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using NTwitter;
using TwitterClient2.Model;
using System.Drawing;
using System.IO;

namespace TwitterClient2.Components
{
    class PanelUserOverviewUser : Panel
    {
        private PictureBox pictureBoxUser;
        public PictureBox PictureBoxUser { get { return this.pictureBoxUser; } }
        private Label labelUserName;
        private TwitterClientModel model = TwitterClientModel.getInstance();
        private User user;
        public User User { get { return this.user; } set { this.user = value; } }
        public PanelUserOverviewUser(User user)
        {
            this.user = user;
            this.InitializeComponent();

        }

        private void InitializeComponent()
        {

            this.pictureBoxUser = new System.Windows.Forms.PictureBox();
            this.labelUserName = new System.Windows.Forms.Label();
            this.SuspendLayout();
            // 
            // pictureBoxUser
            //
            byte[] imageData = model.downLoadData(this.user.ProfileImageUrl.ToString()); //DownloadData function from here
            MemoryStream stream = new MemoryStream(imageData);
            Image img = new Bitmap(stream);
            stream.Close();

            this.pictureBoxUser.Image = img;
            this.pictureBoxUser.Location = new System.Drawing.Point(10, 10);
            this.pictureBoxUser.Name = "pictureBoxUser";
            this.pictureBoxUser.Size = new System.Drawing.Size(50, 50);
            // 
            // labelUserName
            // 
            this.labelUserName.Location = new System.Drawing.Point(10, 0);
            this.labelUserName.Font = new System.Drawing.Font("Tahoma", 7F, System.Drawing.FontStyle.Bold);
            this.labelUserName.Name = "labelUserName";
            this.labelUserName.Size = new System.Drawing.Size(55, 10);
            this.labelUserName.Text = this.user.ScreenName;
            // 
            // PanelUserOverviewUser
            // 
            this.Controls.Add(this.labelUserName);
            this.Controls.Add(this.pictureBoxUser);
            this.Size = new Size(70, 70);
            this.BackColor = System.Drawing.Color.WhiteSmoke;
            this.ResumeLayout(false);

        }

    }
}
